﻿using Microsoft.Maps.MapControl;
using MyFloridaHouse.libSvOpenDistricts.MapTileLayers;

namespace MyFloridaHouse.SilverlightOpenDistricts
{

    public partial class MainPage
    {
        // this is a VIEW trigger that listens for an event in the VIEW-MODEL

        public MapTileLayer openStreetMapsTileLayer;

        private void InitializeOpenStreetMaps()
        {
            this.openStreetMapsTileLayer = new MapTileLayer();
            openStreetMapsTileLayer.TileSources.Add(new OpenStreetMapsTileSource());
            viewModelBase.isOpenStreetMapsVisible = false;
        }

        public void onToggleOpenStreetMapsVisibility()
        {
            if (viewModelBase.isOpenStreetMapsVisible)
            {
                // use open street maps
                this.MyXamlMainMap.Children.Insert(0, openStreetMapsTileLayer);
            }
            else
            {
                // turn off openStreetMaps
                this.MyXamlMainMap.Children.Remove(openStreetMapsTileLayer);

            }
        }

        // End VIEW trigger
    }
}
